<?php 
session_cache_limiter('private, must-revalidate');
include 'checklogin.php';
?>
<!doctype html public "-//w3c//dtd html 4.0 transitional//en" >
<html>
<head>
<meta charset="UTF-8">
<title>电子商务数据上报系统</title>
<link href="css/style.css" type="text/css" rel="stylesheet">
<script src="js/jquery.min.js"></script>
<script type="text/javascript">
function checkInput(obj){
	var reg=/^(([0-9]+.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*.[0-9]+)|([0-9]*[1-9][0-9]*))$/;
	if(!reg.test($(obj).val())){
		//alert(reg.test($(obj).val())+"---"+$(obj).val());
		$(obj).val("");
	}
}
function check(){
	debugger;
	f1 = false;
	f2 = false;
	$.each($("input[class=a]"),function(k,v){
		if($.trim($(v).val()).length > 0){
			f1 = true;
		}
	});
 	$.each($("input[class=b]"),function(k,v){
    	if($.trim($(v).val()).length > 0){
    		f2 = true;
    	}
	});
	if (f1 || f2){
		return true;
	}else{
		alert("请先填写上报的数据");
		return false;
	}
}
</script>
</head>
<body>
<table cellspacing="0" cellpadding="0" width="100%" border="0">
	<tr><td align="center">
		<br/><h1>站点交易信息采集(日报表)</h1>
		<table border="0" cellspacing="0" cellpadding="0" style="width:70%;margin-bottom:8px;">
			<tr>
				<td>
					<strong>站点编码：</strong>
					<span><?php echo $_SESSION['code']?></span>
				</td>
				<td>
					<strong>站点名称：</strong>
					<span><?php echo $_SESSION['name']?></span>
				</td>
				<td>
					<strong>站点类型：</strong>
					<span><?php echo $_SESSION['countyTypeName']?></span>
				</td>
			</tr>
		</table>
		<form action="uploadData.php" onsubmit="return check()" method="post" style="margin:0px;padding:0px;">
		<table border="0" cellspacing="0" cellpadding="0" style="width:70%;margin-bottom:8px;">
			<tr><td valign="top">
				<table cellspacing="0" cellpadding="3" rules="all"
					style="border-width:1px;border-style:solid;width:100%;border-collapse:collapse;">
					<tr align="center">
						<td style="background-color:#E3F2F2;width:30%;">
							<span>代买商品</span>
						</td>
						<td style="background-color:#E3F2F2;width:70%;">
							代买总金额
						</td>
					</tr>
					<?php
                    include '../include/Mysql.Class.php';
                    include '../include/config.php';
                    $mysql = new mysql($mydbhost, $mydbuser, $mydbpw, $mydbname, $conn, $mydbcharset);
                    $mysql->query('select * from commodity where flag=1');
                    while($row = $mysql->fetch_assoc()){
                    ?>
                    <tr>
						<td align="right"><span><?php echo $row["commodityName"] ?></span></td>
						<td>
						    <input type="hidden" name="buyId[]" value="<?php echo $row["commodityId"] ?>" />
						    <input type="hidden" name="buyName[]" value="<?php echo $row["commodityName"] ?>" />
							<input class="a" name="buy[]" type="text" onblur="checkInput(this)" style="width:60%;"/>
						</td>
					</tr>
                    <?php 
                    }
                    ?>
				</table>
			</td><td valign="top">
				<table cellspacing="0" cellpadding="3" rules="all"
					style="border-width:1px;border-style:solid;width:100%;border-collapse:collapse;">
					<tr align="center">
						<td style="background-color:#E3F2F2;width:30%;">
							<span>销售商品</span>
						</td>
						<td style="background-color:#E3F2F2;width:70%;">
							销售总金额
						</td>
					</tr>
					<?php 
    					$mysql->query('select * from commodity where flag=2');
    					while($row = $mysql->fetch_assoc()){
					?>
					<tr>
						<td align="right"><span><?php echo $row["commodityName"] ?></span></td>
						<td>
						    <input type="hidden" name="sellId[]" value="<?php echo $row["commodityId"] ?>" />
						    <input type="hidden" name="sellName[]" value="<?php echo $row["commodityName"] ?>" />
							<input class="b" name="sell[]" type="text" onblur="checkInput(this)" style="width:60%;"/>
						</td>
					</tr>
					<?php 
                    }
					?>
					
				</table>
			</td></tr>
		</table>
		
		<br/>
		<input type="submit" name="btnSave" value=" 上 报  " class="systembutton"/>
		<input type="reset" name="btnSave" value=" 重 置  " class="systembutton"/>
		</form>
	</td></tr>
	<tr><td>
		<div headertext="错误提示：" showmessagebox="true" showsummary="false"
		style="color: red; height: 300px; width: 400px; display: none;"></div>
	</td></tr>
</table>
</body>
</html>